import { getUserAddressInfo,getUserTradeInfo } from "@/api"

const state = {
  addressInfo:[],
  tradeInfo:{}
}
const mutations = {
  GETUSERADDRESSINFO(state, addressInfo) {
    state.addressInfo = addressInfo
  },
  GETUSERTRADEINFO(state, tradeInfo) {
    state.tradeInfo = tradeInfo
  }
}
const actions = {
 async getUserAddressInfo({commit}) {
    let result =  await getUserAddressInfo()
    if (result.code == 200) {
      commit('GETUSERADDRESSINFO',result.data)
    }
  },
  async getUserTradeInfo({ commit }){
    let result = await getUserTradeInfo()
    console.log('获取trade信息结果为',result)
    if (result.code == 200) {
      commit('GETUSERTRADEINFO',result.data)
    }
  }
}
const getters = {

}

export default {
  state,
  mutations,
  actions,
  getters
}
